package com.weiqk.pmdemo.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.weiqk.pmdemo.controller.R.R;
import com.weiqk.pmdemo.dto.ApplyLinkInDto;
import com.weiqk.pmdemo.dto.ExcelDto;
import com.weiqk.pmdemo.pojo.Project;
import com.weiqk.pmdemo.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Api(tags="项目接口")
@Slf4j
@RestController
@RequestMapping("/Project")
public class ProjectController {
    @Autowired
    ProjectService projectService;

    @ApiOperation("查询全部")
    @ApiOperationSupport(author = "EDSION")
    @ResponseBody
    @GetMapping("/findAll")
    public R findAll()   {
     return new R(true,projectService.findAll()) ;
    }
    @ApiOperation("根据id删除")
    @ApiOperationSupport(author = "EDSION")
    @ResponseBody
    @DeleteMapping("/{id}")
    public R deleteById(@PathVariable Integer id)   {
        return new R(projectService.deleteById(id),null) ;
    }
    @ApiOperation("更新")
    @ApiOperationSupport(author = "EDSION")
    @PostMapping("update")
    @ResponseBody
    public R Update(@RequestBody Project project){
        R r = new R();
        r.setS((projectService.update(project)));
        return r;
    }
    @ApiOperation("新增")
    @ApiOperationSupport(author = "EDSION")
    @PostMapping("put")
    @ResponseBody
    public R Put(@RequestBody Project project){
        R r = new R();
        r.setS((projectService.put(project)));
        return r;
    }
    @ApiOperation("查询某项目实际金额")
    @ApiOperationSupport(author = "EDSION")
    @ResponseBody
    @PostMapping("/{id}")
    public R findTure(@PathVariable Integer id)   {
        int money = projectService.counttruenum(id);
        return new R(true,"实际金额"+money) ;
    }
}
